﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Geometry {
    public struct Normal {
        public float x, y, z;

        public Normal(float x, float y, float z) {
            this.x = x;
            this.y = y;
            this.z = z;
        }
        public Normal(Vector v) {
            this.x = v.x;
            this.y = v.y;
            this.z = v.z;
        }

        public static explicit operator Vector(Normal n) {
            return new Vector(n.x, n.y, n.z);
        }

        public static Normal operator +(Normal u, Normal v) {
            return new Normal(u.x + v.x, u.y + v.y, u.z + v.z);
        }
        public static Normal operator -(Normal u, Normal v) {
            return new Normal(u.x - v.x, u.y - v.y, u.z - v.z);
        }
        public static Normal operator *(Normal v, float a) {
            return new Normal(a * v.x, a * v.y, a * v.z);
        }
        public static Normal operator *(float a, Normal v) {
            return v * a;
        }
        public static Normal operator /(Normal v, float a) {
            float r = 1.0f / a;
            return v * r;
        }
        
        public static float dot(Normal u, Normal v) {
            return u.x * v.x + u.y * v.y + u.z * v.z;
        }
        public static float dot(Normal u, Vector v) {
            return Normal.dot(u, (Normal)v);
        }
        public static float absDot(Normal u, Normal v) {
            return Math.Abs(Normal.dot(u, v));
        }
        public static float absDot(Normal u, Vector v) {
            return Math.Abs(Normal.dot(u, v));
        }

        public float dot(Normal v) { return Normal.dot(this, v); }
        public float dot(Vector v) { return Normal.dot(this, v); }
        public float absDot(Normal v) { return Normal.absDot(this, v); }
        public float absDot(Vector v) { return Normal.absDot(this, v); }
    }
}
